<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <meta name="twitter:site" content="@metroui">
    <meta name="twitter:creator" content="@pimenov_sergey">
    <meta name="twitter:card" content="summary">
    <meta name="twitter:title" content="Metro 4 Components Library">
    <meta name="twitter:description" content="Metro 4 is an open source toolkit for developing with HTML, CSS, and JS. Quickly prototype your ideas or build your entire app with responsive grid system, extensive prebuilt components, and powerful plugins  .">
    <meta name="twitter:image" content="https://metroui.org.ua/images/m4-logo-social.png">

    <meta property="og:url" content="https://metroui.org.ua/v4/index.html">
    <meta property="og:title" content="Metro 4 Components Library">
    <meta property="og:description" content="Metro 4 is an open source toolkit for developing with HTML, CSS, and JS. Quickly prototype your ideas or build your entire app with responsive grid system, extensive prebuilt components, and powerful plugins  .">
    <meta property="og:type" content="website">
    <meta property="og:image" content="https://metroui.org.ua/images/m4-logo-social.png">
    <meta property="og:image:secure_url" content="https://metroui.org.ua/images/m4-logo-social.png">
    <meta property="og:image:type" content="image/png">
    <meta property="og:image:width" content="968">
    <meta property="og:image:height" content="504">

    <meta name="author" content="Sergey Pimenov">
    <meta name="description" content="The Charms bars is a systems toolbars that houses for important services.  The most popular HTML, CSS, and JS library in Metro style.">
    <meta name="keywords" content="HTML, CSS, JS, Metro, CSS3, Javascript, HTML5, UI, Library, Web, Development, Framework">

    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
    <link rel="icon" href="favicon.ico" type="image/x-icon">

    <link href="metro/css/metro-all.css?ver=@@b-version" rel="stylesheet">
    <link href="highlight/styles/github.css" rel="stylesheet">
    <link href="docsearch/docsearch.min.css" rel="stylesheet">
    <link href="css/site.css" rel="stylesheet">

    <title>Charms - Metro 4 :: Popular HTML, CSS and JS library</title>

    <style>
        .charms {
            display: flex;
            align-content: center;
            justify-content: center;
            padding: 5rem;
        }

        .charms.right-side, .charms.left-side  {
            flex-direction: column;
        }
    </style>
</head>
<body class="m4-cloak">

<header data-role="html-container" data-insert-mode="replace" data-html-source="header.html"></header>

<div data-role="html-container" data-insert-mode="replace" data-html-source="sidebar-menu.html"></div>

<div class="container-fluid docs-content">

    <div class="row flex-xl-nowrap">

            <div class="d-none d-block-xl cell-xl-2 order-2 border-left bd-light toc-wrapper">
                <h5>Table of contents</h5>
                <hr/>
                <ul class="toc-nav">
                    <li class="toc-entry"><a href="#">Charms</a></li>
                    <li class="toc-entry"><a href="#_charms_about">About charms</a></li>
                    <li class="toc-entry"><a href="#_charms_position">Position</a></li>
                    <li class="toc-entry"><a href="#_charms_opacity">Opacity</a></li>
                    <li class="toc-entry"><a href="#_charms_events">Events</a></li>
                    <li class="toc-entry"><a href="#_charms_methods">Methods</a></li>
                    <li class="toc-entry"><a href="#_charms_methods">Customize</a></li>
                </ul>
            </div>

            <main class="cell-xl-10 order-1 pr-1-sx pl-1-sx pr-5-md pl-5-md">
                <div class="place-right d-none d-block-lg" style="width: 200px;">
                    <img src="images/logo.png" class="w-100" alt="">
                </div>

                <h1>Charms</h1>
                <p class="text-leader">
                    The Charms bars is a systems toolbars that houses for important services. Create additional control area with charm component.
                </p>

                <!-- ads-html -->

                <h3 id="_charms_about">About charms</h3>
                <p>
                    The Charms bars is a systems toolbars that houses for important services.
                    The Charms bars is a vertical or horizontal toolbar, found on the: <code>right-side</code>, <code>left-side</code>, <code>top-side</code> or <code>bottom-side</code> of the screen.
                </p>

                <p>
                    To create <code>charms</code> add attribute <code>data-role="charms"</code> to block element. and setup charms position with attribute <code>data-position="right|left|top|bottom"</code>.
                </p>
                <pre><code class="html">
                    &lt;div data-role="charms" data-position="right"&gt;&lt;/div&gt;
                </code></pre>

                <div data-role="charms" id="default-charms"><div>Default charms</div></div>
                <div class="example text-center">
                    <button class="button" onclick="$('#default-charms').data('charms').toggle()">Default charms</button>
                </div>

                <h3 id="_charms_position">Position</h3>
                <p>
                    You can setup position for <code>charms</code>.
                    To set <code>position</code> add attribute <code>data-position</code> with one of values: <code>right</code>, <code>left</code>, <code>top</code> or <code>bottom</code>.
                </p>
                <pre><code class="html">
                    &lt;div data-role="charms" data-position="top"&gt;&lt;div&gt;top&lt;/div&gt;&lt;/div&gt;
                    &lt;div data-role="charms" data-position="bottom"&gt;&lt;div&gt;bottom&lt;/div&gt;&lt;/div&gt;
                    &lt;div data-role="charms" data-position="left"&gt;&lt;div&gt;left&lt;/div&gt;&lt;/div&gt;
                    &lt;div data-role="charms" data-position="right"&gt;&lt;div&gt;right&lt;/div&gt;&lt;/div&gt;
                </code></pre>

                <div data-role="charms" data-position="top" id="top-charms"><div>top</div></div>
                <div data-role="charms" data-position="bottom" id="bottom-charms"><div>bottom</div></div>
                <div data-role="charms" data-position="left" id="left-charms"><div>left</div></div>
                <div data-role="charms" data-position="right" id="right-charms"><div>right</div></div>

                <div class="example text-center">
                    <button class="button" onclick="$('#top-charms').data('charms').toggle()">Top</button>
                    <button class="button" onclick="$('#bottom-charms').data('charms').toggle()">Bottom</button>
                    <button class="button" onclick="$('#left-charms').data('charms').toggle()">Left</button>
                    <button class="button" onclick="$('#right-charms').data('charms').toggle()">Right</button>
                </div>

                <h3 id="_charms_opacity">Opacity</h3>
                <p>
                    To set <code>opacity</code> for charms use attribute <code>data-opacity</code>. The value can be between <code>0</code> and <code>1</code>.
                </p>
                <pre><code class="html">
                    &lt;div data-role="charms" data-opacity=".5"&gt;&lt;/div&gt;
                </code></pre>

                <div data-role="charms" data-opacity=".5" id="opacity-charms"><div>opacity</div></div>
                <div class="example text-center">
                    <button class="button" onclick="$('#opacity-charms').data('charms').toggle()">opacity</button>
                </div>

                <!-- ads-html -->

                <h3 id="_charms_events">Events</h3>
                <p>
                    When charms works, it generated the numbers of events. You can use callback for this event to behavior with charms.
                </p>
                <table class="table cell-border table-border options-table">
                    <thead>
                    <tr>
                        <th>Event</th>
                        <th>Data-*</th>
                        <th>Desc</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td>onCharmsCreate(el)</td>
                        <td><code>data-on-charms-create</code></td>
                        <td>Fired when charms was created</td>
                    </tr>
                    <tr>
                        <td>onOpen(el)</td>
                        <td><code>data-on-open</code></td>
                        <td>Fired when charms open</td>
                    </tr>
                    <tr>
                        <td>onClose(el)</td>
                        <td><code>data-on-close</code></td>
                        <td>Fired when charms close</td>
                    </tr>
                    </tbody>
                </table>
                <pre><code>
                    &lt;div data-role="charms"
                        data-on-open="console.log('charms was opened')"
                        data-on-close="console.log('charms was closed')"
                    &gt;&lt;/div&gt;
                </code></pre>

                <h3 id="_charms_methods">Methods</h3>
                <p>
                    You can use charms methods ti interact with the charms component.
                </p>
                <ul>
                    <li><strong>open()</strong> - open charms</li>
                    <li><strong>close()</strong> - close charms</li>
                    <li><strong>toggle()</strong> - toggle charms</li>
                    <li><strong>opacity()</strong> - get charms opacity value</li>
                    <li><strong>opacity(val)</strong> - eet charms opacity</li>
                </ul>
                <pre><code>
                    var charms = $(el).data('charms');
                    charms.open();
                    charms.close();
                    charms.toggle();
                    charms.opacity(.5);
                    console.log(charms.opacity());
                </code></pre>
                <p>
                    Also Metro 4 also implements a special object for working with the component <code>Metro.charms</code> with same methods:
                </p>
                <ul>
                    <li><strong>check(el)</strong> - Check element is a charm</li>
                    <li><strong>isOpen(el)</strong> - Check charms is open</li>
                    <li><strong>open(el)</strong> - open specific charms</li>
                    <li><strong>close(el)</strong> - close specific charms</li>
                    <li><strong>toggle(el)</strong> - toggle specific charms</li>
                    <li><strong>opacity(el, opacity)</strong> - set opacity for specific charms</li>
                </ul>
                <pre><code>
                    &lt;div data-role="charms" id="specific-charms"&gt;&lt;/div&gt;

                    &lt;script&gt;
                        Metro.charms.open("#specific-charms");
                    &lt;/script&gt;
                </code></pre>

                <h3 id="_charms_customize">Customize</h3>
                <p>
                    You can use attribute <code>data-cls-charms="..."</code> to set additional classes for charms.
                </p>

            </main>
        </div>

    </div>

    <script src="docsearch/docsearch.min.js"></script>


    <script src="metro/js/metro.js?ver=@@b-version"></script>
    <script src="highlight/highlight.pack.js"></script>
    <script src="js/clipboard.min.js"></script>
    <script src="js/site.js"></script>
    <!-- ads-script -->
    <!-- ga-script -->
    <!-- hit-ua -->
</body>
</html>